package cn.dankal.flyaudio.personal;

import android.graphics.Bitmap;
import android.view.View;
import android.widget.ImageView;


import androidx.appcompat.widget.AppCompatTextView;
import cn.dankal.basiclib.base.activity.BaseActivity;
import cn.dankal.basiclib.util.CodeUtils;
import cn.dankal.basiclib.util.SizeUtils;
import cn.dankal.flyaudio.R;

/**
 * <pre>
 *     e-mail : junfeng.nie@duntech.com.cn
 *     time   : 16/7/2020
 *     desc   :
 *     version: cn.dankal.flyaudio.oss
 *     Copyright: Copyright（c）2018
 *     Company:
 * </pre>
 *
 * @author niejunfeng
 */
public class CardQrCodeActivity extends BaseActivity {

    @Override
    protected int getLayoutId() {
        return R.layout.activity_card_qr_code;
    }

    @Override
    protected void initComponents() {
        String time = getIntent().getStringExtra("time");
        String code = getIntent().getStringExtra("code");
        String name = getIntent().getStringExtra("name");
        findViewById(R.id.iv_onback).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                onBackPressed();
            }
        });

        AppCompatTextView tvName = findViewById(R.id.tv_name);
        tvName.setText(name);
        AppCompatTextView tvTime = findViewById(R.id.tv_time);
        tvTime.setText("有效期:"+time);

        Bitmap qrcode = CodeUtils.createImage(code, SizeUtils
                .dp2px(this, 208f), SizeUtils.dp2px(this, 208f), null);

        ImageView ivCode = findViewById(R.id.iv_qr_code);
        ivCode.setImageBitmap(qrcode);
    }
}
